package com.yanqu.road.entity.activity.climbtower;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@FieldTypeAnnotation(tableName = "t_u_climb_tower_data", autoSave = true)
public class UserClimbTowerData extends DataObject {

    @FieldTypeAnnotation(select = true, update = true, desc = "活动ID")
    private int activityId;

    @FieldTypeAnnotation(select = true, update = true, desc = "玩家ID")
    private long userId;

    @FieldTypeAnnotation(desc = "经验值")
    private BigInteger exp = BigInteger.ZERO;

    @FieldTypeAnnotation(desc = "积分")
    private int score;

    @FieldTypeAnnotation(desc = "能力值/实力")
    private BigInteger ability = BigInteger.ZERO;

    @FieldTypeAnnotation(desc = "灵气/炼妖体力")
    private int power;

    @FieldTypeAnnotation(desc = "上次恢复时间")
    private long lastRecoverPowerTime;

    @FieldTypeAnnotation(desc = "抽奖次数")
    private int drawTimes;

    @FieldTypeAnnotation(desc = "当前层")
    private int cellNum;

    @FieldTypeAnnotation(desc = "爬塔事件")
    private UserClimbTowerEvent event = new UserClimbTowerEvent();

    @FieldTypeAnnotation(desc = "符鬼数量")
    private Map<Integer, Integer> runeNumMap = new HashMap<>();

    @FieldTypeAnnotation(desc = "已经处理的层")
    private List<Integer> preHandleList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "新幻境首通记录")
    private int maxTopCell;

    @FieldTypeAnnotation(desc = "确认过的最近一次被击败时间")
    private long lastDefeatedTime;

    @FieldTypeAnnotation(desc = "在新幻境的层数")
    private int topCellNum;


    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if(this.activityId != activityId) {
            this.activityId = activityId;
            setUpdateOption();
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if(this.userId != userId) {
            this.userId = userId;
            setUpdateOption();
        }
    }

    public BigInteger getExp() {
        return exp;
    }

    public void setExp(BigInteger exp) {
        if(this.exp != exp) {
            this.exp = exp;
            setUpdateOption();
        }
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        if(this.score != score) {
            this.score = score;
            setUpdateOption();
        }
    }

    public BigInteger getAbility() {
        return ability;
    }

    public void setAbility(BigInteger ability) {
        if(this.ability != ability) {
            this.ability = ability;
            setUpdateOption();
        }
    }

    public int getPower() {
        return power;
    }

    public void setPower(int power) {
        if(this.power != power) {
            this.power = power;
            setUpdateOption();
        }
    }

    public long getLastRecoverPowerTime() {
        return lastRecoverPowerTime;
    }

    public void setLastRecoverPowerTime(long lastRecoverPowerTime) {
        if(this.lastRecoverPowerTime != lastRecoverPowerTime) {
            this.lastRecoverPowerTime = lastRecoverPowerTime;
            setUpdateOption();
        }
    }

    public int getDrawTimes() {
        return drawTimes;
    }

    public void setDrawTimes(int drawTimes) {
        if(this.drawTimes != drawTimes) {
            this.drawTimes = drawTimes;
            setUpdateOption();
        }
    }

    public int getCellNum() {
        return cellNum;
    }

    public void setCellNum(int cellNum) {
        if(this.cellNum != cellNum) {
            this.cellNum = cellNum;
            setUpdateOption();
        }
    }

    public UserClimbTowerEvent getEvent() {
        return event;
    }

    public void setEvent(UserClimbTowerEvent event) {
        if(this.event != event) {
            this.event = event;
            setUpdateOption();
        }
    }

    public Map<Integer, Integer> getRuneNumMap() {
        return runeNumMap;
    }

    public void setRuneNumMap(Map<Integer, Integer> runeNumMap) {
        this.runeNumMap = runeNumMap;
    }

    public void addRuneNum(int type, int num){
        int oldNum = runeNumMap.getOrDefault(type, 0);
        runeNumMap.put(type, num + oldNum);
        setUpdateOption();
    }

    public List<Integer> getPreHandleList() {
        return preHandleList;
    }

    public void setPreHandleList(List<Integer> preHandleList) {
        if(this.preHandleList != preHandleList) {
            this.preHandleList = preHandleList;
            setUpdateOption();
        }
    }

    public void addPreHandle(int cellId){
        if(!this.preHandleList.contains(cellId)){
            this.preHandleList.add(cellId);
            setUpdateOption();
        }
    }

    public int getMaxTopCell() {
        return maxTopCell;
    }

    public void setMaxTopCell(int maxTopCell) {
        if (this.maxTopCell != maxTopCell) {
            this.maxTopCell = maxTopCell;
            setUpdateOption();
        }
    }

    public long getLastDefeatedTime() {
        return lastDefeatedTime;
    }

    public void setLastDefeatedTime(long lastDefeatedTime) {
        if (this.lastDefeatedTime != lastDefeatedTime) {
            this.lastDefeatedTime = lastDefeatedTime;
            setUpdateOption();
        }
    }

    public int getTopCellNum() {
        return topCellNum;
    }

    public void setTopCellNum(int topCellNum) {
        if (this.topCellNum != topCellNum) {
            this.topCellNum = topCellNum;
            setUpdateOption();
        }
    }
}
